package com.kgc.sportscircle.controller;

import com.kgc.sportscircle.pojo.Sportsuser;
import com.kgc.sportscircle.redis.LoginPrefix;
import com.kgc.sportscircle.redis.RedisService;
import com.kgc.sportscircle.utils.GetCookie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/isLogin")
public class IsLoginController {

    @Autowired
    RedisService redisService;
    @RequestMapping("/islogin.json")
    public Sportsuser isLogin(HttpServletRequest request){
        //获得令牌
       String token = GetCookie.getSportsUserofCookie(request);
        //根据本地cookie获取redis中用户信息
        Sportsuser sportsuser = redisService.get(LoginPrefix.getLoginList,token,Sportsuser.class);
        return sportsuser;
    }
}
